package org.dce.screencapturer;

import java.util.AbstractMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

import org.dce.screencapturer.actions.ScreenCapturerAction;

public class ActionCollection
	extends AbstractMap<String, ScreenCapturerAction>
	implements Iterable<ScreenCapturerAction> {

	private Map<String, ScreenCapturerAction> actions = new LinkedHashMap<String, ScreenCapturerAction>(); 
	
	public ActionCollection(){
	}
	
	public ActionCollection(Iterable<? extends ScreenCapturerAction> actions){
		addAll(actions);
	}
	
	public void addAll(Iterable<? extends ScreenCapturerAction> actions){
		for (ScreenCapturerAction action:actions){
			add(action);
		}
	}
	
	public void addAll(ScreenCapturerAction ... actions){
		for (ScreenCapturerAction action:actions){
			add(action);
		}
	}
	
	@Override
	public Set<java.util.Map.Entry<String, ScreenCapturerAction>> entrySet() {
		return actions.entrySet();
	}

	@Override
	public Iterator<ScreenCapturerAction> iterator() {
		return actions.values().iterator();
	}
	
	public void add(ScreenCapturerAction action){
		actions.put((String)action.getValue(ScreenCapturerAction.ID_KEY), action);
	}

}
